﻿using System;

namespace Hive.Core.Common.Shell
{
    /// <summary>
    /// Provides options for the console shell.
    /// </summary>
    public class ConsoleShellOptions
    {
        private int forceQuitCancelKeyPressRepetitions;
        private TimeSpan forceQuitCancelKeyPressTimeout;

        /// <summary>
        /// Create a console shell options initialized to to defaults.
        /// </summary>
        public ConsoleShellOptions()
        {
            forceQuitCancelKeyPressRepetitions = 3;
            forceQuitCancelKeyPressTimeout = TimeSpan.FromSeconds(1);
            PromptColor = ConsoleColor.Green;
            StandardOutputColor = ConsoleColor.Gray;
            StandardErrorColor = ConsoleColor.DarkRed;
            ErrorMessageColor = ConsoleColor.Red;
            WarningMessageColor = ConsoleColor.Yellow;
            ImportantMessageColor = ConsoleColor.White;
            InfoMessageColor = ConsoleColor.Gray;
            DebugMessageColor = ConsoleColor.DarkGray;
            Verbosity = Verbosity.Normal;
        }

        /// <summary>
        /// Gets or sets the number of repeated cancel key presses before the application will forcibly terminate.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The application will forcibly terminate if the cancel key is pressed
        /// <see cref="ForceQuitCancelKeyPressRepetitions" /> times within no more than
        /// <see cref="ForceQuitCancelKeyPressTimeout"/> time.
        /// </para>
        /// <para>
        /// The default is 3.
        /// </para>
        /// </remarks>
        public int ForceQuitCancelKeyPressRepetitions
        {
            get { return forceQuitCancelKeyPressRepetitions; }
            set
            {
                if (value <= 0)
                    throw new ArgumentOutOfRangeException("value", "The number of repetitions must be greater than zero.");
                forceQuitCancelKeyPressRepetitions = value;
            }
        }

        /// <summary>
        /// Gets or sets the interval of time during which repeated cancel key presses may cause the application to forcibly terminate.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The application will forcibly terminate if the cancel key is pressed
        /// <see cref="ForceQuitCancelKeyPressRepetitions" /> times within no more than
        /// <see cref="ForceQuitCancelKeyPressTimeout"/> time.
        /// </para>
        /// <para>
        /// The default is 1 second.
        /// </para>
        /// </remarks>
        public TimeSpan ForceQuitCancelKeyPressTimeout
        {
            get { return forceQuitCancelKeyPressTimeout; }
            set
            {
                if (value.Ticks <= 0)
                    throw new ArgumentOutOfRangeException("value", "The interval must be greater than zero.");
                forceQuitCancelKeyPressTimeout = value;
            }
        }

        /// <summary>
        /// Gets or sets the prompt color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.Green" />.
        /// </para>
        /// </remarks>
        public ConsoleColor PromptColor { get; set; }

        /// <summary>
        /// Gets or sets the standard output color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.Gray" />.
        /// </para>
        /// </remarks>
        public ConsoleColor StandardOutputColor { get; set; }

        /// <summary>
        /// Gets or sets the standard error color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.DarkRed" />.
        /// </para>
        /// </remarks>
        public ConsoleColor StandardErrorColor { get; set; }

        /// <summary>
        /// Gets or sets the error message color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.Red" />.
        /// </para>
        /// </remarks>
        public ConsoleColor ErrorMessageColor { get; set; }

        /// <summary>
        /// Gets or sets the warning message color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.Yellow" />.
        /// </para>
        /// </remarks>
        public ConsoleColor WarningMessageColor { get; set; }

        /// <summary>
        /// Gets or sets the important message color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.White" />.
        /// </para>
        /// </remarks>
        public ConsoleColor ImportantMessageColor { get; set; }

        /// <summary>
        /// Gets or sets the info message color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.Gray" />.
        /// </para>
        /// </remarks>
        public ConsoleColor InfoMessageColor { get; set; }

        /// <summary>
        /// Gets or sets the debug message color.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="ConsoleColor.DarkGray" />.
        /// </para>
        /// </remarks>
        public ConsoleColor DebugMessageColor { get; set; }

        /// <summary>
        /// Gets or sets the verbosity of the shell.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The default is <see cref="Shell.Verbosity.Normal" />.
        /// </para>
        /// </remarks>
        public Verbosity Verbosity { get; set; }
    }
}
